<?php

class Admin_Form_Page extends Zend_Dojo_Form
{

    public function __construct($cid = NULL, $fid = NULL)
    {
        parent::__construct();
        
        $this->addElement('FilteringSelect', 'cid', array(
                          'label' => '分类',
                          'storeId' => 'categoryStore',
                          'storeType' => 'dojo.data.ItemFileReadStore',
                          'autoComplete' => true,
                          'storeParams' => array('url' => '/admin/category/list/cid/'.$cid.'/fid/'.$fid),
                          'dijitParams' => array('searchAttr' => 'name')))
             ->addElement('TextBox', 'title', array('label'=>'标题', 'required'=>true))
             ->addElement('editor', 'body', array('label'=>'内容', 'required'=>true, 'dojoType'=>'dijit.Editor'))
             ->addElement('RadioButton', 'status', array('label'=>'状态',
                           'separator'=>'','multiOptions'=>array(0=>'草稿',1=>'发布'), 'value'=>1))
             ->addElement('RadioButton', 'comment', array('label'=>'允许评论',
                           'separator'=>'','multiOptions'=>array(0=>'否',1=>'是'), 'value'=>1))
             ->addElement('FilteringSelect', 'star', array('label'=>'星级',
                           'multiOptions'=>array(1=>'一星', 2=>'二星', 3=>'三星',4=>'四星',5=>'五星')))
             ->addElement('RadioButton', 'top', array('label'=>'是否置顶',
                           'separator'=>'','multiOptions'=>array(0=>'否',1=>'是'), 'value'=>1))
             ->addElement('SubmitButton', 'submit', array('label'=>'提交', 'ignore' => true));
             
        //装饰器
        $this->clearDecorators();
        $this->addDecorator('FormElements')
             ->addDecorator('HtmlTag', array('tag' => 'table', 'class' => 'pageCreate'))
             ->addDecorator('Form');
             
        $this->setElementDecorators(array(
                'DijitElement',// 注意这里不使用'ViewHelper'
                'Errors',
                array('decorator' => array('td' => 'HtmlTag'), 'options' => array('tag' => 'td')),
                array('Label', array('tag' => 'td')),
                array('decorator' => array('tr' => 'HtmlTag'), 'options' => array('tag' => 'tr')),
           ));

    }
}

